from django.db import models

# Create your models here.
from django.contrib.auth.models import User
from django.utils import timezone
from datetime import datetime, timedelta


class Todo(models.Model):
    todo = models.CharField('内容', max_length=50)
    flag = models.CharField(max_length=2,default='1')
    priority = models.CharField(max_length=2, default='0')
    pub_date = models.DateTimeField('时间')

    def __str__(self):
        return self.todo

    def was_published_recently(self):
        if timezone.now() - timedelta(days=1) <=self.pub_date:
            return True
        else:
            return False